package com.itheima.controller;

import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhangyan
 * @date 2021/2/24 19:39
 */
@RestController
@RequestMapping("/register")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("/findAll")
    public List<User> findAll(){
        List<User> userList = userService.findAll();
        return userList;
    }

    @RequestMapping("/add")
    public void add(User user){
        userService.add(user);
    }


    @RequestMapping("/findByName")
    public List<User> findByName(String name){
        List<User> userList = userService.findByName(name);
        return userList;
    }
}
